/*******************************************************************************
 * Copyright 2011 Towee.net
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package net.towee.client.widgets.upload;

import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;

/**
 * This interface define base logic of uploading widget.
 * 
 * @author viiv.c58@gmail.com (Artem Artem'ev)
 */
public interface UploadForm extends IsWidget, HasWidgets, HasUploadHandlers {
	public static final int MAX_QUEUE_SIZE = 100;
	public static final int MAX_CONCURENT_UPLOADING = 1;
	
	/**
	 * Add handler that invoked when new file start uploading
	 * 
	 * @param handler
	 * @return
	 */
	HandlerRegistration addUploadStartHandler(UploadStartHandler handler);
	
	/**
	 * @return number 0-100 of global uploading progress
	 */
	int getGlobalProgress();

	/**
	 * @return size of all uploading/uploaded files or -1 if not presented
	 *         (HTML4 mode)
	 */
	long getGlobalSize();

	/**
	 * Cancel all uploading. It invoke cancel handler for each UploadItem
	 */
	void cancelAll();

	/**
	 * Set maximum number of uploading files
	 * 
	 * @param number
	 */
	void setFilesNumberLimit(int number);

	/**
	 * Set maximum file size for filtering on client side if browser can.
	 * 
	 * @param size
	 */
	void setMaxFileSize(long size);
	
	/**
	 * @return true if dnd file uploading supported
	 */
	boolean isDropSupported();

	Widget getUploadInputWidget();
}